#include <bits/stdc++.h>
using namespace std;
int n;
int number;
int num;
int r[100005];
int b[100005];
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    //cout<<"+++++++++++++++++++++++++";
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
    }
    sort(r+1,r+n+1);
    //cout<<r[1];
    int len=1;
    int j=1;
    for(int i=2;i<=n;i++)
    {
        if(r[i]==r[i-1])
        {
            j++;
        }
        else
        {
            b[len]=j;
            len++;
            j=1;
        }
    }
    b[len]=j;
    for(int i=1;i<=len;i++)
    {
        if(i==1)
        {
            number+=b[i];
            continue;
        }
        if(b[i]>number-num)
        {
            num=number;
        }
        else
        {
            num+=b[i];
        }
        number+=b[i];
    }
    cout<<n-num;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
